import 'package:expensy_flutter/_inner_packages.dart';
import 'package:expensy_flutter/_external_packages.dart';

class DeviceHelper {
  static double totalVerticalHeight({BuildContext context}) {
    return MediaQuery.of(context).size.height;
  }

  static double statusBarTopPadding({BuildContext context}) {
    return MediaQuery.of(context).padding.top;
  }

  static double availableHeight(
      {BuildContext context, double appBarHeight = 0}) {
    return MediaQuery.of(context).size.height -
        MediaQuery.of(context).padding.top -
        appBarHeight;
  }

  static double curScaleFactor(BuildContext context) {
    return MediaQuery.of(context).textScaleFactor;
  }

  static bool isSimpleLandscape(BuildContext context) {
    return MediaQuery.of(context).orientation == Orientation.landscape;
  }

  static bool isLandscape(NativeDeviceOrientation orientation) {
    return (orientation == NativeDeviceOrientation.landscapeRight ||
        orientation == NativeDeviceOrientation.landscapeLeft);
  }

  static bool isLandscapeLeft(NativeDeviceOrientation orientation) {
    return (orientation == NativeDeviceOrientation.landscapeLeft);
  }

  static bool isLandscapeRight(NativeDeviceOrientation orientation) {
    return (orientation == NativeDeviceOrientation.landscapeRight);
  }

  static bool isSimplePortrait(BuildContext context) {
    return MediaQuery.of(context).orientation == Orientation.portrait;
  }

  static bool isPortrait(NativeDeviceOrientation orientation) {
    return [
      NativeDeviceOrientation.portraitDown,
      NativeDeviceOrientation.portraitUp
    ].contains(orientation);
  }

  static bool isPortraitUp(NativeDeviceOrientation orientation) {
    return (orientation == NativeDeviceOrientation.portraitUp);
  }

  static bool isPortraitDown(NativeDeviceOrientation orientation) {
    return (orientation == NativeDeviceOrientation.portraitDown);
  }

  static bool deviceIsIOS(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.iOS;
  }

  static bool deviceIsMacOS(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.macOS;
  }

  static bool deviceIsAppleMade(BuildContext context) {
    return [TargetPlatform.iOS, TargetPlatform.macOS]
        .contains(Theme.of(context).platform);
  }

  static bool deviceIsAndroid(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.android;
  }

  static bool deviceIsWindows(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.windows;
  }

  static bool deviceIsLinux(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.linux;
  }

  static bool deviceIsFuchsia(BuildContext context) {
    return Theme.of(context).platform == TargetPlatform.fuchsia;
  }

  static bool deviceIsAnyOf(
      BuildContext context, List<TargetPlatform> platformsList) {
    return platformsList.contains(Theme.of(context).platform);
  }
}
